#ifndef AVALON_TCPCLIENTSOCKETCHANNEL_HPP
#define AVALON_TCPCLIENTSOCKETCHANNEL_HPP
#include "Avalon/IO/Channel.hpp"
#include "Avalon/Network/TcpSocketConnection.hpp"
#include "Avalon/Network/TcpSocketReader.hpp"
#include "Avalon/Network/TcpSocketWriter.hpp"

namespace Avalon {
namespace Network {

  /*! \class TcpClientSocketChannel
   *  \brief Implements a client socket.
   */
  class TcpClientSocketChannel : public IO::Channel {
    public:

      //! Constructs a TcpClientSocketChannel.
      /*!
        \param address The IP address to connect to.
      */
      TcpClientSocketChannel(const IpAddress& address);

      virtual ~TcpClientSocketChannel();

      //! Sets the TCP no delay option.
      /*!
        \param noDelay <code>true</code> iff the TCP no delay option should be
                       enabled.
      */
      void SetNoDelay(bool noDelay);

      //! Gets the TCP no delay option.
      bool GetNoDelay() const;

      virtual TcpSocketConnection& GetConnection();

      virtual TcpSocketReader& GetReader();

      virtual TcpSocketWriter& GetWriter();

    private:
      friend class TcpServerSocket;
      boost::shared_ptr<TcpSocketReader> m_reader;
      boost::shared_ptr<TcpSocketWriter> m_writer;
      boost::shared_ptr<TcpSocketConnection> m_connection;

      TcpClientSocketChannel(
        const boost::shared_ptr<TcpSocketConnection>& connection,
        const boost::shared_ptr<TcpSocketReader>& reader,
        const boost::shared_ptr<TcpSocketWriter>& writer);
  };
}
}

#endif // AVALON_TCPCLIENTSOCKETCHANNEL_HPP
